﻿using System.Threading.Tasks;

namespace net.xBei.WebApi.Repository {
    /// <summary>
    /// 
    /// </summary>
    public interface IAuthorizationRepository {
        /// <summary>
        /// 当前用户ID，未登录返回-1
        /// </summary>
        int UserId { get; }
        /// <summary>
        /// 是否系统用户（API之间调用）
        /// </summary>
        bool IsSystemUser { get; }
        /// <summary>
        /// 
        /// </summary>
        Microsoft.AspNetCore.Http.HttpContext? HttpContext { get; }
        /// <summary>
        /// 是否管理员
        /// </summary>
        /// <returns></returns>
        Task<bool> IsAdminAsync();
        /// <summary>
        /// 是否管理员
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<bool> IsAdminAsync(int userId);
        /// <summary>
        /// 是否后台用户
        /// </summary>
        /// <returns></returns>
        Task<bool> IsBackUserAsync();

        /// <summary>
        /// 判断是否后台用户
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<bool> IsBackUserAsync(int userId);
        /// <summary>
        /// 检查用户权限
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="controller"></param>
        /// <param name="action"></param>
        /// <param name="permissionKey"></param>
        /// <returns></returns>
        Task<bool> CheckUserPermissionAsync(int userId, string controller, string action, string permissionKey = "A");
    }
}
